﻿namespace EOrm
{
    /// <summary>
    /// 数据库
    /// </summary>
    public class Database
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public Database()
        {
            string dbProviderPath = OrmProviderLoader.GetProviderPath();
            DbInstance = Db.CreateInstance(dbProviderPath, "");
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dbProviderPath">数据库服务提供者的库文件路径</param>
        public Database(string dbProviderPath)
        {
            DbInstance = Db.CreateInstance(dbProviderPath, "");
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dbProviderPath">数据库服务提供者的库文件路径</param>
        /// <param name="jsonConfigPathOrConString">json配置文件路径或连接字符串</param>
        public Database(string dbProviderPath, string jsonConfigPathOrConString)
        {
            DbInstance = Db.CreateInstance(dbProviderPath, jsonConfigPathOrConString);
        }

        /// <summary>
        /// 数据库实例
        /// </summary>
        public Db DbInstance { get; set; }
    }
}
